import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
import { DemoModule } from './demo/demo.module';
import { UploadModule } from './upload/upload.module';
import databaseConfig from '../config/database.config';
import { PrismaService } from './prisma.service';
import { OssService } from './oss.service';
import { UserModule } from './user/user.module';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { AuthModule } from './auth/auth.module';
import { MonitorModule } from './monitor/monitor.module';

@Module({
  imports: [
    /**
     * 前端静态页面
     */
    ServeStaticModule.forRoot({
      renderPath: '*', // rootPath下所有文件都可以访问
      serveRoot: '/ui', // 路由前缀
      rootPath: join(process.cwd(), 'public/app'), //静态路径, 要考虑到编译后到路径
    }),
    /**
     * 公开资源文件
     */
    ServeStaticModule.forRoot({
      renderPath: '*', // rootPath下所有文件都可以访问
      serveRoot: '/assets', // 路由前缀
      rootPath: join(process.cwd(), 'public/assets'), //静态路径, 要考虑到编译后到路径
    }),
    ConfigModule.forRoot({ 
      envFilePath: '.env', 
      isGlobal: true,
      load: [databaseConfig]
    }),
    UploadModule,
    DemoModule,
    UserModule,
    AuthModule,
    MonitorModule,
  ],
  controllers: [
    // UserPostController,
  ],
  providers: [
    PrismaService,
    OssService
  ]
})
export class AppModule {}
